package com.meeting.config;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置类，用于注册拦截器
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**") // 拦截所有请求
                .excludePathPatterns(
                    "/admin/login", // 排除登录接口
                    "/customer/register",
                    "/customer/login",
                    "/employee/login", // 排除登录接口
                    "/employee/register",
                    "/swagger-ui.html", // Swagger UI主页
                    "/swagger-ui/**", // Swagger UI相关资源
                    "/v3/api-docs/**", // OpenAPI规范文档
                    "/swagger-resources/**", // Swagger资源
                    "/webjars/**", // Swagger使用的前端依赖
                    "/error",
                    "/druid/**",
                    "/doc.html",
                    "/*.html",
                    "/dashboard.html",
                    "/css/**",           // CSS文件
                    "/js/**",            // JavaScript文件
                    "/images/**",        // 图片文件
                    "/fonts/**",         // 字体文件
                    "/favicon.ico"      // 网站图标
                );
    }
}